using EnvDTE;
using Microsoft.Practices.RecipeFramework;
using VSSDKAssist.Assets.Actions.Base;
using VSSDKAssist.Assets.Helpers;

namespace VSSDKAssist.Assets.Actions.VisualStudio
{
	/// <summary>
	/// Action that inserts text to a CodeElement
	/// </summary>
	public class InsertTextToCodeElementAction : ActionBase
	{
		private CodeElement codeElement;

		/// <summary>
		/// Gets or sets the code element.
		/// </summary>
		/// <value>The code element.</value>
		[Input(Required = true)]
		public CodeElement CodeElement
		{
			get { return codeElement; }
			set { codeElement = value; }
		}

		private string textToInsert;

		/// <summary>
		/// Gets or sets the text to insert.
		/// </summary>
		/// <value>The text to insert.</value>
		[Input(Required = true)]
		public string TextToInsert
		{
			get
			{
				return this.textToInsert;
			}
			set
			{
				this.textToInsert = value;
			}
		}

		/// <summary>
		/// Called when [execute].
		/// </summary>
		protected override void OnExecute()
		{
			FileCodeModelHelper.InsertTextToCodeElement(this.CodeElement, this.TextToInsert);
		}
	}
}